package com.szu.smart_illustrator.rest;

import com.szu.smart_illustrator.common.R;
import com.szu.smart_illustrator.dto.param.user.*;
import com.szu.smart_illustrator.entity.User;
import com.szu.smart_illustrator.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户相关接口
 *
 * @author 冼铧城
 * @date 2023/11/23
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    UserService userService;




    /**
     * 添加用户
     * @param dto
     * @return {@link R}<{@link User}>
     */
    @PostMapping("addUser")
    public R<User> addUser(@RequestBody AddUserParamDto dto){
     return  userService.addUser(dto);
}

    /**
     * 登录
     *
     * @param dto
     * @return {@link R}<{@link User}>
     */
    @PostMapping("login")
    public R<User> login(@RequestBody LoginParamDto dto){
     return  userService.login(dto);
}


    /**
     * 获取验证码
     *
     * @param dto
     * @return {@link R}<{@link String}>
     */
    @PostMapping("GetVerificationCode")
    public R<String> getVerificationCode(@RequestBody GetVerificationCodeParamDto dto){
     return userService.getVerificationCode(dto);
}


    /**
     * 修改密码
     *
     * @param dto
     * @return {@link R}<{@link User}>
     */
    @PostMapping("ChangePasswd")
     public R<User> changePasswd(@RequestBody ChangePasswdParamDto dto){
      return  userService.changePasswd(dto);
 }


    /**
     * 获取用户info
     *
     * @param dto
     * @return {@link R}<{@link User}>
     */
    @PostMapping("GetUserInfo")
     public R<User> getUserInfo(@RequestBody GetUserInfoParamDto dto){
      return  userService.getUserInfo(dto);
 }


    /**
     * 编辑用户信息
     * @param dto
     * @return {@link R}<{@link User}>
     */
    @PostMapping("EditUserInfo")
     public R<User> editUserInfo(@RequestBody EditUserInfoParamDto dto){
      return  userService.editUserInfo(dto);
 }

    /**
     * 重置密码
     *
     * @param dto
     * @return {@link R}<{@link String}>
     */
    @PostMapping("ResetPasswd")
     public R<String> resetPasswd(@RequestBody ResetPasswdParamDto dto){
      return userService.resetPasswd(dto);
 }






}
